package vg.services.graph_view_manager.realization.graph_comparison;

import javax.swing.JComponent;

import vg.services.data_base_manager.data.graph.Graph;
import vg.services.graph_view_manager.interfaces.graph_comparison.AGraphComparison;
import vg.services.graph_view_manager.interfaces.graph_view.AGraphView;
import vg.services.graph_view_manager.realization.graph_comparison.algorithm.GraphComparisonAlghoritm;
import vg.services.main_manager.MainManager;

public class GraphComparation extends AGraphComparison {
	// Main data
	private GraphComparisonAlghoritm comparator;
	private AGraphView mcs_graph_view;
	
	// Mutex
	private Object general_mutex = new Object();
	
	/**
	 * Constructor.
	 * @param g1 - first graph
	 * @param g2 - second graph
	 */
	public GraphComparation(Graph g1, Graph g2) {
		this.comparator = new GraphComparisonAlghoritm(g1, g2);
	}
	
	@Override
	public String getTabTitle() {
		return null;
	}
	
	@Override
	public void setTabTitle(String title) {
		
	}
	
	@Override
	public JComponent getView() {
		synchronized (general_mutex) {
			if (mcs_graph_view == null) {
				Graph g = comparator.run();
				mcs_graph_view = MainManager.graphViewManager.newGraphView(g);
			}
			return mcs_graph_view.getView();
		}
	}
}
